package Homework1

object Homework1 {
  val money = 100
  val price = 2
  val bottleToBeer = 3
  val capToBeer = 5

  def buy(bottles: Int, caps: Int): Int = {
    if (bottles < 3 && caps < 5){
      return 0
    }
    val beer1 = bottles / bottleToBeer
    val beer2 = caps / capToBeer
    val beers = beer1 + beer2
    beers + buy(beers + bottles % bottleToBeer, caps % capToBeer)
  }

  def main(args: Array[String]): Unit = {
    val beerNumber = money / price
    var result = beerNumber
    result += buy(beerNumber, beerNumber)
    println("可以买" + result + "瓶啤酒")
  }
}
